package com.ndp.fb.rdb.model;

import com.ndp.fb.rdb.annotation.Column;
import com.ndp.fb.rdb.annotation.ColumnType;
import com.ndp.fb.rdb.annotation.Id;
import com.ndp.fb.rdb.annotation.NoSave;
import com.ndp.fb.rdb.annotation.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by Sisi on 14-10-19.
 */
@Setter
@Getter
@NoArgsConstructor
@Table("ad_campaign_group")
public class AdCampaignGroup implements Serializable {

    private static final long serialVersionUID = -4963319258108348133L;

    /**
     * id
     */
    @Id
    private Long id;

    /**
     * campaignGroupId
     */
    @Column(value = "campaign_group_id", type = ColumnType.Long)
    private Long campaignGroupId;

    /**
     * fbAccountId
     */
    @Column(value = "fb_account_id", type = ColumnType.Long)
    private Long fbAccountId;

    /**
     * timezone
     */
    @Column("time_zone")
    private String timezone;

    /**
     * publishBatchId
     */
    @Column(value = "publish_batch_id", type = ColumnType.Long)
    private Long publishBatchId;

    /**
     * publishBatchName
     */
    @Column("publish_batch_name")
    private String publishBatchName;

    /**
     * productConfId
     */
    @Column(value = "product_conf_id", type = ColumnType.Long)
    private Long productConfId;

    /**
     * fbConnectionObjectId
     */
    @Column(value = "fb_connection_object_id", type = ColumnType.Long)
    private Long fbConnectionObjectId;

    /**
     * connectionObjectName
     */
    @Column("connection_object_name")
    private String connectionObjectName;

    /**
     * configuration
     */
    @Column("configuration")
    private String configuration;

    /**
     * name
     */
    @Column("name")
    private String name;

    /**
     * startTime
     */
    @Column(value = "start_time", type = ColumnType.Date)
    private Date startTime;

    /**
     * stopTime
     */
    @Column(value = "stop_time", type = ColumnType.Date)
    private Date stopTime;

    /**
     * campaignGroupStatus
     */
    @Column("campaign_group_status")
    private String campaignGroupStatus;

    /**
     * effictiveStatus
     */
    @NoSave
    private String effectiveStatus;

    /**
     * startUtcTime
     */
    @Column(value = "start_utc_time", type = ColumnType.Long)
    private Long startUtcTime;

    /**
     * stopUtcTime
     */
    @Column(value = "stop_utc_time", type = ColumnType.Long)
    private Long stopUtcTime;
    @Column(value = "updated_time", type = ColumnType.Date)
    private Date updatedTime;
    @Column(value = "created_time", type = ColumnType.Date)
    private Date createdTime;
    @Column(value = "updated_utc_time", type = ColumnType.Long)
    private Long updatedUtcTime;
    @Column(value = "created_utc_time", type = ColumnType.Long)
    private Long createdUtcTime;
    @Column("objective")
    private String objective;
    //add from v0.0.2
    @Column("promoted_object")
    private String promotedObject;

    //add from 0.8.0
    @Column(value = "source_status", type = ColumnType.Int)
    private Integer sourceStatus;
    //add from 0.8.6
    @Column(value = "name_status", type = ColumnType.Int)
    private Integer nameStatus;
    @Column(value = "open_status", type = ColumnType.Int)
    private Integer openStatus;
    @Column("buying_type")
    private String buying_type;
    @Column(value = "can_use_spend_cap", type = ColumnType.Int)
    private Integer can_use_spend_cap;
    @Column(value = "topline_id", type = ColumnType.Int)
    private Integer topline_id;
    @Column(value = "spend_cap", type = ColumnType.Int)
    private Integer spend_cap;
    @Column("adlabels")
    private String adlabels;

    private Long ecTemplateMaterielId;

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (obj instanceof AdCampaignGroup) {
            if (this.campaignGroupId != null && this.campaignGroupId.equals(((AdCampaignGroup) obj).getCampaignGroupId())) {
                if (this.updatedUtcTime != null && this.updatedUtcTime.equals(((AdCampaignGroup) obj).getUpdatedUtcTime())) {
                    return true;
                }
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        return campaignGroupId.hashCode();
    }

}
